package com.glacier.common.core.exception;

import java.time.Instant;

/**
 * date 2022-11-05 17:00
 * 业务异常
 *
 * @author glacier
 * @version 1.0
 */
public class BizException extends RuntimeException {
	
	private static final long serialVersionUID = -257432313588488173L;
	/**
	 * 错误编码
	 */
	private final String code;
	/**
	 * 错误信息
	 */
	private final String msg;
	/**
	 * 时间戳
	 */
	private final Instant time;
	
	
	public BizException(String code, String msg) {
		this(code, msg, null);
	}
	
	public BizException(String code, String msg, Throwable cause) {
		super(cause);
		this.code = code;
		this.msg = msg;
		this.time = Instant.now();
	}
	
	public String getCode() {
		return code;
	}
	
	public String getMsg() {
		return msg;
	}
	
	public Instant getTime() {
		return time;
	}
	
	@Override
	public String toString() {
		return "BizException{" +
				"code='" + code + '\'' +
				", msg='" + msg + '\'' +
				", time=" + time +
				'}';
	}
}
